/*package com.eastmelon.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import com.aspose.words.Document;
import com.aspose.words.HeaderFooter;
import com.aspose.words.HeaderFooterType;
import com.aspose.words.HorizontalAlignment;
import com.aspose.words.Node;
import com.aspose.words.NodeCollection;
import com.aspose.words.NodeType;
import com.aspose.words.Paragraph;
import com.aspose.words.ProtectionType;
import com.aspose.words.RelativeHorizontalPosition;
import com.aspose.words.RelativeVerticalPosition;
import com.aspose.words.Section;
import com.aspose.words.Shape;
import com.aspose.words.ShapeType;
import com.aspose.words.VerticalAlignment;
import com.aspose.words.WrapType;

public class WordUtil {
	// 加图片水印   并且根据参数设置保护  返回文件File对象
	*//**
	 * @param inputStream  doc输入流
	 * @param imageStream  图片输入流
	 * @param savePath     保存路径
	 * @param READ_ONLY    是否只读
	 * @param ALLOW_ONLY_REVISIONS 是否允许修改
	 * @param ALLOW_ONLY_COMMENTS  是否允许注释
	 * @param ALLOW_ONLY_FORM_FIELDS   是否允许填写窗体（不能编辑复制）
	 * 返回文件的输入流
	 *//*
	public static File addWaterMark(InputStream inputStream,
			InputStream imageStream, String savePath, boolean READ_ONLY,
			boolean ALLOW_ONLY_REVISIONS, boolean ALLOW_ONLY_COMMENTS,
			boolean ALLOW_ONLY_FORM_FIELDS) {
		FileInputStream fis = null;
		Document doc=null;
		File docFile=null;
		try {
			doc = new Document(inputStream);
			RemoveWatermark(doc);
			Shape watermark = new Shape(doc, ShapeType.IMAGE);
			watermark.getImageData().setImage(imageStream);
			watermark.setWidth(400);
			watermark.setHeight(400);
			watermark.setWrapType(WrapType.NONE);
			watermark.setBehindText(true);
			watermark
					.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
			watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);
			watermark
					.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
			watermark.setVerticalAlignment(VerticalAlignment.CENTER);
			Paragraph watermarkPara = new Paragraph(doc);
			watermarkPara.appendChild(watermark);
			for (Section sect : doc.getSections()) {
				InsertWatermarkIntoHeader(watermarkPara, sect,
						HeaderFooterType.HEADER_PRIMARY);
				InsertWatermarkIntoHeader(watermarkPara, sect,
						HeaderFooterType.HEADER_FIRST);
				InsertWatermarkIntoHeader(watermarkPara, sect,
						HeaderFooterType.HEADER_EVEN);
			}
			if(READ_ONLY){
				doc.protect(ProtectionType.READ_ONLY);
			}
			if(ALLOW_ONLY_REVISIONS){
				doc.protect(ProtectionType.ALLOW_ONLY_REVISIONS);
			}
			if(ALLOW_ONLY_COMMENTS){
				doc.protect(ProtectionType.ALLOW_ONLY_COMMENTS);
			}
			if(ALLOW_ONLY_FORM_FIELDS){
				doc.protect(ProtectionType.ALLOW_ONLY_FORM_FIELDS);
			}
			
			doc.save(savePath);
			docFile = new File(savePath);
			fis = new FileInputStream(docFile);
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			try {
				fis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return docFile;
	}

	private static void InsertWatermarkIntoHeader(Paragraph watermarkPara,
			Section sect, int headerType) {
		HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(
				headerType);
		if (header == null) {
			// There is no header of the specified type in the current section,
			// create it.
			header = new HeaderFooter(sect.getDocument(), headerType);
			sect.getHeadersFooters().add(header);
		}
		// Insert a clone of the watermark into the header.
		try {
			header.appendChild(watermarkPara.deepClone(true));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private static void RemoveWatermark(Document doc)
    {
        @SuppressWarnings("rawtypes")
		NodeCollection headerColl = doc.getChildNodes(NodeType.HEADER_FOOTER, true, false);

        if (headerColl == null || headerColl.getCount() == 0)
            return;

        Node[] headerNodes = headerColl.toArray();

        int headerCount = headerNodes.length;
        for (int i = 0; i < headerCount; i++)
        {
            HeaderFooter header = (HeaderFooter)headerNodes[i];
            if (header.isHeader())
            {
                @SuppressWarnings("rawtypes")
				NodeCollection shapeColl = header.getChildNodes(NodeType.SHAPE, true, false);
                if (shapeColl.getCount() > 0)
                {
                    Node[] shapeNodes = shapeColl.toArray();
                    
                    for (Node shape : shapeNodes) {
//                    	 if (((Shape)shape).isWordArt())
                             if (header.getParentSection() != null)
                                 header.remove();
					}

                }
            }
        }
    }
}
*/